<?php
namespace Home\Controller;
use Think\Controller;
class JbsjController extends BaseController {
  

    //解绑上级
    public function jb_apply()
    { 

      if (!IS_POST)
        {
          $userid=session('user.id');
          $user=M('user')->find($userid);
          $up_id=$user['invite_id'];

          $up_user=M('user')->find($up_id);
          $this->assign('user',$user);
          $this->assign('up_user',$up_user);
          $this->display();
        }
        else
        {    $map['user_id']=session('user.id');
            $find=M('jb_records')->where($map)->find();
            if ($find) {
              $this->error('你已经申请过解绑，请等待审核结果');
            }
            $data=$_POST;
            $data['ctime'] = time();
            $data['user_id'] = session('user.id');
            $data['user_mobile'] = session('user.mobile');
            $data['user_truename'] = session('user.truename');
            $res=M('jb_records')->add($data);
            if ($res) {
              $this->success("申请解绑成功,等待审核");
            }
        }


      
    }
}
